package com.offcn.controller;

import com.offcn.po.User;
import com.offcn.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/User")
public class UserController {

    @Autowired
    private IUserService userService;


    @GetMapping("/")
    public List<User> getAll(){
        System.out.println(111);
        System.out.println(userService.getAll());
        return null;
    }

    @PostMapping("/")
    public String save(User user){
        System.out.println(111);
        userService.save(user);
        return "保存成功";
    }

    @PutMapping("/")
    public String update(User user){
        userService.update(user);
        return "修改成功";
    }

    @GetMapping("/{id}")
    public User findOne(@PathVariable("id") Long uid){
        return userService.findOne(uid);
    }

    @DeleteMapping("/")
    public String delete(@RequestParam("id") Long uid){
        userService.delete(uid);
        return "删除成功";
    }
}
